package com.rockcent.mall.lib.domain;

import com.rockcent.common.domain.IDEntityMall;
import com.rockcent.mall.lib.domain.enumclass.*;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.math.BigDecimal;

/**
 * 平台资金流
 */
@Entity
@Table(name = "merchant_fund_flow")
@DynamicInsert
@DynamicUpdate
public class MerchantFundFlow extends IDEntityMall {

    /**
     * 商家订单号
     */
    @Column(columnDefinition = "varchar(50) comment '商家订单号 有关订单资金时,此字段不能为空'")
    private String merchantOrderNum;

    /**
     * 商家资金
     */
    @Column(columnDefinition = "bigint comment '商家资金 id'")
    private Long merchantFundId;

    /**
     * 商家
     */
    @Column(columnDefinition = "bigint comment '商家 id'")
    private Long merchantId;

    /**
     * 总金额
     */
    @Column(columnDefinition = "DECIMAL(30,10) default 0 comment '总金额'")
    private BigDecimal totalAmount = BigDecimal.valueOf(0);

    /**
     * 核销数
     */
    @Column(columnDefinition = "bigint comment '核销数 当这笔资金变动为服务核销时，此字段不能为空'")
    private Long verifyCount;

    /**
     *冻结金额
     */
    @Column(columnDefinition = "DECIMAL(30,10) default 0 comment '冻结金额'")
    private BigDecimal frozen = BigDecimal.valueOf(0);

    /**
     *可用金额
     */
    @Column(columnDefinition = "DECIMAL(30,10) default 0 comment '可用金额'")
    private BigDecimal availableAmount = BigDecimal.valueOf(0);

    /**
     *操作金额
     */
    @Column(columnDefinition = "DECIMAL(30,10) default 0 comment '操作金额'")
    private BigDecimal operationAmount = BigDecimal.valueOf(0);

    /**
     *交易方向
     */
    @Column(columnDefinition = "varchar(50) comment '交易方向 INCOME(\"收入\", \"+\"), EXPEND(\"支出\", \"-\")'")
    @Enumerated(EnumType.STRING)
    private FundTransactionFlow transactionFlow;

    /**
     *交易类型
     */
    @Column(columnDefinition = "varchar(50) comment '交易类型 SERVICE_FEE(\"服务费收入\")'")
    @Enumerated(EnumType.STRING)
    private MerchantFundFlowTransactionType transactionType;

    /**
     *平台
     */
    @Column(columnDefinition = "bigint comment '平台 id'")
    private Long mallId;

    /**
     * 支付类型
     */
    @Column(columnDefinition = "varchar(30) comment '支付类型 ALL(\"全部\"), ONLINE(\"线上支付\"), OUTLINE(\"线下支付\"),BASE_SERVICE_PAYMENTS(\"基础服务费扣费\"), RECHARGE_MALL(\"平台支付\")'")
    @Enumerated(EnumType.STRING)
    private MerchantPayType payType;

    /**
     *备注
     */
    @Column(columnDefinition = "varchar(255) comment '备注'")
    private String remark;



    /**
     *
     */
    @Column(columnDefinition = "bigint comment 'parent_id'")
    private Long parentId;


    public Long getMallId() {
        return mallId;
    }

    public void setMallId(Long mallId) {
        this.mallId = mallId;
    }

    public BigDecimal getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(BigDecimal totalAmount) {
        this.totalAmount = totalAmount;
    }

    public BigDecimal getFrozen() {
        return frozen;
    }

    public void setFrozen(BigDecimal frozen) {
        this.frozen = frozen;
    }

    public BigDecimal getAvailableAmount() {
        return availableAmount;
    }

    public void setAvailableAmount(BigDecimal availableAmount) {
        this.availableAmount = availableAmount;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public BigDecimal getOperationAmount() {
        return operationAmount;
    }

    public void setOperationAmount(BigDecimal operationAmount) {
        this.operationAmount = operationAmount;
    }

    public FundTransactionFlow getTransactionFlow() {
        return transactionFlow;
    }

    public void setTransactionFlow(FundTransactionFlow transactionFlow) {
        this.transactionFlow = transactionFlow;
    }

    public MerchantFundFlowTransactionType getTransactionType() {
        return transactionType;
    }

    public void setTransactionType(MerchantFundFlowTransactionType transactionType) {
        this.transactionType = transactionType;
    }

    public String getMerchantOrderNum() {
        return merchantOrderNum;
    }

    public void setMerchantOrderNum(String merchantOrderNum) {
        this.merchantOrderNum = merchantOrderNum;
    }

    public Long getMerchantFundId() {
        return merchantFundId;
    }

    public void setMerchantFundId(Long merchantFundId) {
        this.merchantFundId = merchantFundId;
    }

    public Long getMerchantId() {
        return merchantId;
    }

    public void setMerchantId(Long merchantId) {
        this.merchantId = merchantId;
    }

    public Long getParentId() {
        return parentId;
    }

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    public Long getVerifyCount() {
        return verifyCount;
    }

    public void setVerifyCount(Long verifyCount) {
        this.verifyCount = verifyCount;
    }

    public MerchantPayType getPayType() {
        return payType;
    }

    public void setPayType(MerchantPayType payType) {
        this.payType = payType;
    }

    @Override
    public String toString() {
        return "MerchantFundFlow{" +
                "merchantOrderNum='" + merchantOrderNum + '\'' +
                ", id=" + id +
                ", merchantFundId=" + merchantFundId +
                ", dateCreated=" + dateCreated +
                ", merchantId=" + merchantId +
                ", totalAmount=" + totalAmount +
                ", lastUpdated=" + lastUpdated +
                ", verifyCount=" + verifyCount +
                ", isDelete=" + isDelete +
                ", version=" + version +
                ", frozen=" + frozen +
                ", availableAmount=" + availableAmount +
                ", operationAmount=" + operationAmount +
                ", transactionFlow=" + transactionFlow +
                ", transactionType=" + transactionType +
                ", mallId=" + mallId +
                ", payType=" + payType +
                ", remark='" + remark + '\'' +
                ", parentId=" + parentId +
                '}';
    }
}